package com.jvtd.eyl.ui.main.home.classInfo;

import com.jvtd.eyl.base.BasePresenter;
import com.jvtd.eyl.bean.binding.ClassBean;
import com.jvtd.eyl.bean.binding.PeriodicalBean;
import com.jvtd.eyl.bean.http.BannerBean;
import com.jvtd.eyl.data.DbManager;
import com.jvtd.eyl.rxjava.JvtdRxSchedulers;
import com.jvtd.rxjava.JvtdObserverSubscriber;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.CompositeDisposable;

/**
 * 期刊分类信息
 *
 * 作者:chenlei
 * 时间:2018/11/13 4:25 PM
 */
public class ClassInfoPresenter<V extends ClassInfoMvpView> extends BasePresenter<V>
        implements ClassInfoMvpPresenter<V> {

    @Inject
    public ClassInfoPresenter(DbManager dbManager, CompositeDisposable disposable) {
        super(dbManager, disposable);
    }

    @Override
    public void getSecondaryClassList(String id) {
        if (!isAttachView()) return;
        getCompositeDisposable().add(getDbManager().getSecondaryClassList(id).compose(JvtdRxSchedulers.handleObservableResult())
                .subscribeWith(new JvtdObserverSubscriber<List<ClassBean>>(getMvpView()){
                    @Override
                    public void onNext(List<ClassBean> classBeans) {
                        super.onNext(classBeans);
                        getMvpView().getSecondaryClassListSuccess(classBeans);
                    }
                }));
    }
}
